home *** CD-ROM | disk | FTP | other *** search
- unit Unit1;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, Buttons, StdCtrls, ExtCtrls, NewParse, Parsecmp;
-
- type
- TForm1 = class(TForm)
- SpeedButton1: TSpeedButton;
- RadioGroup1: TRadioGroup;
- SpeedButton2: TSpeedButton;
- OpenDialog1: TOpenDialog;
- EOF: TLabel;
- Memo1: TMemo;
- Symbol: TLabel;
- StringL: TLabel;
- IntegerL: TLabel;
- FloatL: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- Comment: TLabel;
- Label13: TLabel;
- Label14: TLabel;
- OpenTag: TLabel;
- CloseTag: TLabel;
- SpeedButton3: TSpeedButton;
- AParser: ThgsParser;
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure SpeedButton3Click(Sender: TObject);
- procedure AParserParse(Sender: TObject; Token: Char;
- var Abort: Boolean);
- private
- { Private declarations }
- DoAbort: boolean;
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.SpeedButton1Click(Sender: TObject);
- var
- AStream: TFileStream;
- begin
- DoAbort := false;
- EOF.Caption := '0';
- Symbol.Caption := '0';
- StringL.Caption := '0';
- IntegerL.Caption := '0';
- FloatL.Caption := '0';
- Comment.Caption := '0';
- OpenTag.Caption := '0';
- CloseTag.Caption := '0';
- Memo1.Lines.Clear;
- AStream := TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
- case RadioGroup1.ItemIndex of
- 0: AParser.ParserType := ptCSV;
- 1: AParser.ParserType := ptText;
- 2: AParser.ParserType := ptPascal;
- 3: AParser.ParserType := ptEnhPas;
- 4: AParser.ParserType := ptHtml;
- end;
- try
- AParser.ParseStream := AStream;
- finally
- AStream.Free;
- end;
- end;
-
- procedure TForm1.SpeedButton2Click(Sender: TObject);
- begin
- OpenDialog1.Execute;
- end;
-
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- DoAbort := false;
- end;
-
- procedure TForm1.SpeedButton3Click(Sender: TObject);
- begin
- DoAbort := true;
- end;
-
- procedure TForm1.AParserParse(Sender: TObject; Token: Char;
- var Abort: Boolean);
- begin
- Application.ProcessMessages;
- Abort := DoAbort;
- case Token of
- toEOF: EOF.Caption := IntToStr(StrToInt(EOF.Caption)+1);
- toSymbol: Symbol.Caption := IntToStr(StrToInt(Symbol.Caption)+1);
- toString: StringL.Caption := IntToStr(StrToInt(StringL.Caption)+1);
- toInteger: IntegerL.Caption := IntToStr(StrToInt(IntegerL.Caption)+1);
- toFloat: FloatL.Caption := IntToStr(StrToInt(FloatL.Caption)+1);
- toComment: Comment.Caption := IntToStr(StrToInt(Comment.Caption)+1);
- toOpenTag: OpenTag.Caption := IntToStr(StrToInt(OpenTag.Caption)+1);
- toCloseTag: CloseTag.Caption := IntToStr(StrToInt(CloseTag.Caption)+1);
- end;
- if (Sender is TCustomParser) then
- Memo1.Lines.Add((Sender as TCustomParser).TokenString);
- end;
-
- end.
-